<script type="text/javascript" src="${ctx }/static/js/pager.js"/>
<script type="text/javascript" src="${ctx }/static/libs/laypage/laypage.js"></script>
<link href="/static/css/ui_page.css" rel="stylesheet" type="text/css"/>

<script>
    $(function () {
        $(document).keydown(function (e) {
            if (e.keyCode == 13) {
                $('#searchForm .sub').click();//处理事件
            }
        });
        $('#searchForm input').bind('keydown', function (event) {
            if (event.keyCode == "13") {
                $('#searchForm .sub').click();//处理事件
            }
        });
        $(".reset").on("click", function () {
            var from = $(this).parents("form").get(0);
            $(from).find("input:text").val("");
            $(from).find("input:number").val("");
            $(from).find("input:radio").val("");
            $(from).find("input:date").val("");
            $(from).find("input:checkbox").val("");
            $(from).find("select").val("");
        });
        $(".sub").on("click", function () {
            $('#page').val(1);
            return true;
        });
    });
    var pageType = $("#pageType").val();
    if (pageType != "1") {

        var url = $("#searchForm").attr("action");

        function pages() {
            var page = parseInt($('#page').val());
            if (page == null || page == '') {
                page = 1;
            }
            var pageSize = parseInt($('#pageSize').val());
            if (pageSize == null || pageSize == '') {
                pageSize = $CONFIG.pageSize;
                $('#pageSize').val(pageSize);
            }
            new Pager('.ui-page', {
                curPage: page,
                pageSize: pageSize,
                totalCount: parseInt($('#count').val()),
                onClick: function (p) {
                    var form = $('#searchForm');
                    $('#page').val(p);
                    form.action = url;
                    form.submit();
                }
            });
        }

        pages();

        function onchangesel(obj) {
            var pagesize = $(obj).val();
            $('#pageSize').val(pagesize);
            $('#page').val(1);
            var form = $('#searchForm');
            form.action = url;
            form.submit();
        }
    }
</script>

